package silo.dungeonbuddy;

import java.util.Vector;
import java.awt.Graphics2D;

public class SquareForm extends Form
{
	private Vector pieces = new Vector();
	
	public SquareForm(String eName, Start eGame, int eX, int eY, int eWidth, int eHeight, String eTitle)
	{
		super(eName,eGame,eX,eY,eWidth,eHeight,eTitle);
	}//constructor
	
	public void function(Graphics2D g)
	{
		if (isFocusOwner())
		{
			// For now, focus is not an issue, since the last window will have focus
			// until it is closed. (see this comment in the "function" sub in the ToolBox class)
			checkButtons(g);
			checkTextBoxes();
		}
		if(doubleClick)
		{
			resolveDoubleClick();
			doubleClick=false;
		}
	}//function
	
	private void resolveDoubleClick()
	{
		for(int i=0;i<images.size();i++)
		{
			FlatImage m = (FlatImage)images.get(i);
			if((mouseX>m.getX())&&(mouseX<(m.getX()+m.getSizeX()))&&(mouseY>m.getY())&&(mouseY<(m.getY()+m.getSizeY())))
			{
				FlatImage o = (FlatImage)pieces.get(images.indexOf(m));
				game.getFormList().add(new StatsForm("frm" + o.getName(),game, 10, 10, 400, 400, "Info: " + o.getName(),o));
				Form f = (Form)game.getFormList().get(game.getFormList().size()-1);
			}
		}//next i
	}//resolveDoubleClick
	
	//GETTERS
	public Vector getPieces()
	{
		return pieces;
	}
}//class SquareForm